/**
 * GAIA Manager 测试文件
 * 用于测试 gaiaManager 的基本功能
 */

import gaiaManager from './utils/gaiaManager.js';

// 测试基本功能
async function testGaiaManager() {
  console.log('=== GAIA Manager 测试开始 ===');
  
  try {
    // 测试连接
    console.log('1. 测试连接功能...');
    const connectResult = await gaiaManager.connect();
    console.log('连接结果:', connectResult);
    
    if (connectResult.success) {
      // 测试获取设备信息
      console.log('\n2. 测试获取设备信息...');
      const deviceInfo = await gaiaManager.getDeviceInfo();
      console.log('设备信息:', deviceInfo);
      
      // 测试获取应用版本
      console.log('\n3. 测试获取应用版本...');
      const appVersion = await gaiaManager.getAppVersion();
      console.log('应用版本:', appVersion);
      
      // 测试音频控制
      console.log('\n4. 测试音频控制...');
      const volume = await gaiaManager.getVolume();
      console.log('当前音量:', volume);
      
      const mute = await gaiaManager.getMute();
      console.log('静音状态:', mute);
      
      // 测试均衡器
      console.log('\n5. 测试均衡器...');
      const eqSupport = await gaiaManager.getEqualizerSupport();
      console.log('均衡器支持:', eqSupport);
      
      if (eqSupport.supported) {
        const eqState = await gaiaManager.getEqualizerState();
        console.log('均衡器状态:', eqState);
        
        const eqBands = await gaiaManager.getEqualizerBands();
        console.log('均衡器频段:', eqBands);
      }
      
      // 测试降噪
      console.log('\n6. 测试降噪...');
      const ancSupport = await gaiaManager.getANCSupport();
      console.log('降噪支持:', ancSupport);
      
      if (ancSupport.supported) {
        const ancState = await gaiaManager.getANCState();
        console.log('降噪状态:', ancState);
        
        const ancMode = await gaiaManager.getANCMode();
        console.log('降噪模式:', ancMode);
      }
      
      // 测试透明模式
      console.log('\n7. 测试透明模式...');
      const transparencySupport = await gaiaManager.getTransparencySupport();
      console.log('透明模式支持:', transparencySupport);
      
      if (transparencySupport.supported) {
        const transparencyState = await gaiaManager.getTransparencyState();
        console.log('透明模式状态:', transparencyState);
        
        const transparencyGain = await gaiaManager.getTransparencyGain();
        console.log('透明模式增益:', transparencyGain);
      }
      
      // 测试啸叫检测
      console.log('\n8. 测试啸叫检测...');
      const howlingSupport = await gaiaManager.getHowlingDetectionSupport();
      console.log('啸叫检测支持:', howlingSupport);
      
      if (howlingSupport.supported) {
        const howlingState = await gaiaManager.getHowlingDetectionState();
        console.log('啸叫检测状态:', howlingState);
        
        const feedbackGain = await gaiaManager.getFeedbackGain();
        console.log('反馈增益:', feedbackGain);
      }
      
      // 测试不利声学处理
      console.log('\n9. 测试不利声学处理...');
      const adverseSupport = await gaiaManager.getAdverseAcousticSupport();
      console.log('不利声学处理支持:', adverseSupport);
      
      if (adverseSupport.supported) {
        const adverseState = await gaiaManager.getAdverseAcousticState();
        console.log('不利声学处理状态:', adverseState);
      }
      
      // 测试滤波器拓扑
      console.log('\n10. 测试滤波器拓扑...');
      const topology = await gaiaManager.getFilterTopology();
      console.log('滤波器拓扑:', topology);
      
      // 断开连接
      console.log('\n11. 断开连接...');
      gaiaManager.disconnect();
      console.log('连接已断开');
      
    } else {
      console.log('连接失败，跳过其他测试');
    }
    
  } catch (error) {
    console.error('测试过程中发生错误:', error);
  }
  
  console.log('\n=== GAIA Manager 测试结束 ===');
}

// 运行测试
testGaiaManager();

